import { request } from "@/utils/service"
import type * as bill from "./types/bill"
import type * as billStatistics from "./types/billStatistics"
import type * as commissions from "./types/commissions"

// #region BillV2-接口
/** 查 */
export function getBillListApi(params: bill.GetTableRequestData) {
  return request<bill.GetTableResponseData>({
    url: "/BillV2/getList",
    method: "get",
    params
  })
}
export function getIndexApi(params: any) {
  return request({
    url: "/BillV2/getIndex",
    method: "get",
    params
  })
}

export function getCountApi(params: any) {
  return request({
    url: "/BillV2/getCount",
    method: "get",
    params
  })
}
// 票面信息
export function getDetailsApi(params: any) {
  return request({
    url: "/BillV2/getDetails",
    method: "get",
    params
  })
}
// 撤销删除
export function doCancelApi(data: any) {
  return request({
    url: "/BillV2/doCancel",
    method: "post",
    data
  })
}
export function doWarehouseApi(data: any) {
  return request({
    url: "/BillV2/warehouse",
    method: "post",
    data
  })
}

export function doBatchWarehouseApi(data: any) {
  return request({
    url: "/BillV2/batchWarehouse",
    method: "post",
    data
  })
}

export function doWarehouseEditApi(data: any) {
  return request({
    url: "/BillV2/warehouseEdit",
    method: "post",
    data
  })
}

export function getBillExportApi(params: any) {
  return request({
    url: "/BillV2/doExport",
    method: "get",
    params
  })
}

export function batchEditApi(data: any) {
  return request({
    url: "/BillV2/batchEdit",
    method: "post",
    data
  })
}

export function doEditBillBackUserApi(data: any) {
  return request({
    url: "/BillV2/doEditBillBackUser",
    method: "put",
    data
  })
}

export function doBatchCrateApi(data: any) {
  return request({
    url: "/BillV2/batchCreate",
    method: "post",
    data
  })
}

export function gethalfHourStatisticsApi(params: any) {
  return request({
    url: "/BillV2/halfHourStatistics",
    method: "get",
    params
  })
}
// #endregion

export function getBillInventorListApi(params: any) {
  return request<any>({
    url: "/BillInventor/getList",
    method: "get",
    params
  })
}

export function getBillInventorIndexApi(params: any) {
  return request({
    url: "/BillInventor/getIndex",
    method: "get",
    params
  })
}

export function getBillInventorCountApi(params: any) {
  return request({
    url: "/BillInventor/getCount",
    method: "get",
    params
  })
}

// #region 统计当前在库票V2
export function billListCurrentApi(params: any) {
  return request({
    url: "/BillInventor/getListCurrent",
    method: "get",
    params
  })
}

export function billListCurrent2Api(params: any) {
  return request({
    url: "/BillInventor/getListCurrent2",
    method: "get",
    params
  })
}
// #endregion

export function doSellApi(data: any) {
  return request({
    url: "/BillInventor/sell",
    method: "post",
    data
  })
}

export function doDeleteApi(data: any) {
  return request({
    url: "/BillInventor/delete",
    method: "delete",
    data
  })
}

export function doBatchSellApi(data: any) {
  return request({
    url: "/BillInventor/batchSell",
    method: "post",
    data
  })
}

export function doBatchSellUploadApi(data: any) {
  return request({
    url: "/BillInventor/batchSellUpload",
    method: "post",
    data
  })
}

export function doSplitApi(data: any) {
  return request({
    url: "/BillInventor/split",
    method: "post",
    data
  })
}

export function getBillInventorExportApi(params: any) {
  return request({
    url: "/BillInventor/doExport",
    method: "get",
    params
  })
}

export function doWithdrawApi(data: any) {
  return request({
    url: "/BillInventor/withdraw",
    method: "post",
    data
  })
}

export function batchWithdrawApi(data: any) {
  return request({
    url: "/BillInventor/batchWithdraw",
    method: "post",
    data
  })
}

export function batchBillInventorEditApi(data: any) {
  return request({
    url: "/BillInventor/batchEdit",
    method: "post",
    data
  })
}

export function inListsApi(params: any) {
  return request({
    url: "/BillInventor/inLists",
    method: "get",
    params
  })
}

export function getInventorDetailsApi(params: any) {
  return request({
    url: "/BillInventor/getDetails",
    method: "get",
    params
  })
}

export function getStatisticsByCompanyTypeApi(params: billStatistics.GetStatisticsRequestData) {
  return request({
    url: "/BillStatistics/getStatisticsByCompanyType",
    method: "get",
    params
  })
}

export function getStatisticsInventoryApi(params: {}) {
  return request({
    url: "/BillStatistics/getStatisticsInventory",
    method: "get",
    params
  })
}

export function getStatisticsIssueApi(params: billStatistics.GetStatisticsRequestData) {
  return request({
    url: "/BillStatistics/getStatisticsIssue",
    method: "get",
    params
  })
}

export function getStatisticsTypeApi(params: billStatistics.GetStatistics2RequestData) {
  return request({
    url: "/BillStatistics/getStatisticsType",
    method: "get",
    params
  })
}

export function getStatisticsUserTypeApi(params: billStatistics.GetStatistics2RequestData) {
  return request({
    url: "/BillStatistics/getStatisticsUserType",
    method: "get",
    params
  })
}

export function getStatisticsUserDetailsTypeApi(params: billStatistics.UserDetailsRequestData) {
  return request({
    url: "/BillStatistics/getStatisticsUserDetailsType",
    method: "get",
    params
  })
}

export function getStatisticsDetailsTypeApi(params: billStatistics.DetailsRequestData) {
  return request({
    url: "/BillStatistics/getStatisticsDetailsType",
    method: "get",
    params
  })
}

// 提成计算
export function getCommissionListApi(params: commissions.ListsRequestData) {
  return request({
    url: "/Commissions/getCommissionList",
    method: "get",
    params
  })
}
// 提成账单
export function getBillCommissionListsApi(params: commissions.ListsPageRequestData) {
  return request({
    url: "/Commissions/getBillCommissionLists",
    method: "get",
    params
  })
}
// 提成账单
export function getBillCommissionExportApi(params: commissions.ListsExportRequestData) {
  return request({
    url: "/Commissions/doExport",
    method: "get",
    params
  })
}

// 历史记录修改
export function editHistoryApi(params: any) {
  return request({
    url: "/BillInventor/editHistory",
    method: "post",
    params
  })
}

// 历史记录修改
export function getBillHistoryApi(params: any) {
  return request({
    url: "/BillInventor/getBillHistory",
    method: "get",
    params
  })
}

// 查询当前待入库的公司
export function getPendingCompaniesApi(params: any) {
  return request({
    url: "/Billv2/getPendingCompanies",
    method: "get",
    params
  })
}

// 查询当前待入库的公司
export function getPendingBillsByCompanyApi(params: any) {
  return request<bill.getPendingBillsByCompanyResponseData>({
    url: "/Billv2/getPendingBillsByCompany",
    method: "get",
    params
  })
}

export function getRemoteSearchApi(params: bill.getRemoteSearchRequestData) {
  return request<bill.getRemoteSearchResponseData>({
    url: "/BillInventor/remoteSearch",
    method: "get",
    params
  })
}

export function doBatchCreateWithCompanyApi(data: any) {
  return request({
    url: "/BillV2/batchCreateWithCompany",
    method: "post",
    data
  })
}

export function deleteByIdApi(params: { inventory_id: number }) {
  return request({
    url: "/BillInventor/deleteById",
    method: "delete",
    params
  })
}

export function deleteBillApi(data: any) {
  return request({
    url: "/BillV2/deleteBill",
    method: "delete",
    data
  })
}
